package com.smile.controller;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smile.commons.page.R;
import com.smile.model.dto.request.AddMediaShareRequestDTO;
import com.smile.model.dto.request.GetMediaDeviceRequestDTO;
import com.smile.model.dto.request.GetMediaRequestDTO;
import com.smile.model.dto.request.GetMqttConfigRequestDTO;
import com.smile.model.response.response.*;
import com.smile.service.ConfigService;
import com.smile.service.MediaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/config")
public class ConfigController {

    @Autowired
    private ConfigService configService;

//    @Autowired
//    private DeviceClient deviceClient;
//
//    @PostMapping("/test/topic")
//    public R test(){
//        return R.ok();
//    }

    @PostMapping(value = "/mqtt")
    public R<GetMqttConfigResponseDTO> getMqtt(@Valid @RequestBody GetMqttConfigRequestDTO getMqttConfigRequestDTO) throws IOException {
        GetMqttConfigResponseDTO getMediaDeviceResponseDTOList = configService.getMqttConfig(getMqttConfigRequestDTO);
        return  R.ok(getMediaDeviceResponseDTOList);
    }

}
